/*
 * =====================================================================================
 *
 *       Filename:  Graphs.h
 *
 *    Description:  An interface to generate graphs of IR.
 *
 *        Version:  1.0
 *        Created:  18-08-2010 05:51:15
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Rodolfo Câmara Villordo (R.C.V.), rodolfovillordo@gmail.com
 *        Company:  
 *
 * =====================================================================================
 */
#ifndef _GRAPHS_H
#define _GRAPHS_H

#include "Digraph.h"
#include "../ThreeAddressInstruction.h"
#include <map>
#include <vector>
#include <string>

using namespace std;
class Graphs {
	private:
		Digraph cfg;
		Digraph htg;
		Digraph dfg;
		Digraph ddg;
		Digraph cdg;
		vector<ThreeAddressInstruction> instructions;
		map<int,int> labels;
		map<int,int> blocks;
		vector< vector<string> >basicBlocksDeclarations;
        int nBlocks;
        
        void controlDependenceGraph( int ini, int end, int root );
        void dataDependenceGraph( );
		void controlFlowGraph( );
    	void hierarchicalTaskGraphs( );
    	void dataFlowGraph( );
		int getLabel( string label );
		int findBlockByLine( int line );
		int findDependence( string value, int position );
		int searchDec( int position, string val );
		void generateDeclarationsTable( );

	public:
		Graphs( vector<ThreeAddressInstruction> threeAddressTable, map<int,int> labels, map<int,int> blocks, int countBlocks )
			: instructions(threeAddressTable), labels(labels), blocks(blocks), cfg(countBlocks + 1), htg(countBlocks + 1), dfg(threeAddressTable.size() + 1), ddg(countBlocks), cdg(countBlocks){
			nBlocks = countBlocks;
		};
		void generateGraphs( );

};
#endif
